
<%@page import="org.biojava.dasobert.das.CapabilityStatus"%><jsp:directive.page session="true" />

<%@ page import="org.biojava.dasobert.dasregistry.*"%>

<jsp:useBean id="register" class="dasregistry.registryBean"	scope="page" />
<jsp:setProperty name="register" property="*" />

<jsp:directive.page import="dasregistry.dasClientLink" />
<jsp:directive.page	import="org.biojava.dasobert.dasregistry.DasSourceComparator" />
<jsp:directive.page import="org.biojava.dasobert.dasregistry.DasSource" />
<jsp:directive.page import="org.biojava.services.das.registry.DasClient" />
<jsp:directive.page import="org.biojava.services.das.registry.DasRegistrySql" />
<jsp:directive.page import="org.biojava.services.das.registry.AutoActivation" />
<jsp:directive.page import="dasregistry.ActivationURLCreator" />
<jsp:directive.page import="java.util.Date" />
<jsp:directive.page import="java.util.Map" />
<jsp:directive.page import="java.util.List" />
<jsp:directive.page import="java.util.Comparator" />
<jsp:directive.page import="java.text.SimpleDateFormat" />
<%@ page import="org.biojava.dasobert.das.Capabilities"%>
<%@ page import="org.biojava.services.das.dao.Role" %>
<%@ page import="org.biojava.services.das.dao.RegistryUser" %>
<%@ page import="org.biojava.services.das.registry.UserManager" %>
<%@ page import="org.biojava.services.das.dao.ProjectBean"%>

<%@page import="org.biojava.services.das.registry.ShowLinkCapability"%>
<%@page import="org.biojava.services.das.registry.CapabilityLinkBean"%>
<jsp:directive.page import="org.biojava.dasobert.dasregistry.DasSource" />
<%@ page import="org.biojava.dasobert.das.Capabilities"%>
<%@page import="java.util.HashMap"%>
<jsp:directive.page import="org.springframework.beans.factory.BeanFactory"/>
<jsp:directive.page import="org.springframework.context.support.ClassPathXmlApplicationContext"/>
<jsp:directive.page import="org.biojava.dasobert.dasregistry.RegistryTimer"/>


<%
	// init
	response.setHeader("Cache-Control","private"); //HTTP 1.1
response.setHeader("Pragma","private"); //HTTP 1.0
response.setDateHeader ("Expires", -1); //prevents caching at the proxy server


	String findAction = request.getParameter("cmd");
	String sort       = request.getParameter("sort");
	String reverse    = request.getParameter("reverse");

	DasClient[] clients = ActivationURLCreator.CONFIG_DAS_CLIENTS;
	ActivationURLCreator activCreator = new ActivationURLCreator();

	BeanFactory ctx=(new ClassPathXmlApplicationContext("SpringDAO.xml"));
		DasRegistrySql registry=(DasRegistrySql)ctx.getBean("registryBean");

	int DEFAULT_STEPSIZE = 10;
%>


<%
	String title = "Available DAS sources";
	String header = title;
	
	if ( (findAction != null) && (findAction.equals("showmine"))) {
		title = "My DAS sources";
		header = title;
		
	}
%>

<%@ include file="pagehead.jsp" %>
    
<%
    	if ( email != null ) {
    %><script type="text/javascript">
<!--	
function checkUncheckAll(flag) {
     var theForm = document.getElementById('dassourceaction');
     var z = 0;
	 for(z=0; z<theForm.length;z++){
      	if(theForm[z].type == 'checkbox' ){
	  		theForm[z].checked = flag;
	  	}
	 }
}

function submitAction(object){
	var pos = object.options[object.selectedIndex].value;
	var theForm = document.getElementById('dassourceaction');
	
	if ( pos != 0 ) {
	
		if (pos == 'delete'){
			var ok = confirmation();
			if ( ok )
				theForm.submit();
		} else {
			theForm.submit();
		}
	}
}

function confirmation() {
	var answer = confirm("Are you sure you want to delete this DAS source?")
	if (answer){
		return true;	
	}
	else{
		return false;
	}
}

//--></script>
<%
	}
%>
    
<jsp:include page="openwindowscript.jsp" />
    
<body onload="initDynamicOptionLists();">
<%@ include file="pagebodystart.jsp" %>

<div id="normalcontent">
<div class="contentarea">

<%
	String message= (String)request.getAttribute("message");
	if ( message != null ){
%><p><strong><%=message%></strong></p><%
	}
%>

<h2>Available DAS Data Sources</h2>
<p>
<%
	// include file="keywordsearch.jsp"
%> <!-- the search menu --> 

<%
 	String keyword = "";
 	String keywordForTypes="";

  	if ((findAction != null) && (findAction.equals("keyword"))) {
  		keyword = request.getParameter("keyword");
  		register.setCSTypes(new String[0]);
  		register.setCapabilities(new String[0]);
  		register.setLabels(new String[0]);
  		register.setOrganism("");
 %>filter by: <b><%=keyword%></b>
<%
	}else if ((findAction != null) && (findAction.equals("keywordForTypes"))) {
 		keywordForTypes = request.getParameter("keywordForTypes");
 		register.setCSTypes(new String[0]);
 		register.setCapabilities(new String[0]);
 		register.setLabels(new String[0]);
 		register.setOrganism("");
%>filter by types with: <b><%=keywordForTypes%></b>
<%
	} else if ((findAction != null) && ( findAction.equals("showmine"))) {
%>DAS sources for user <b><%=email%></b>		
		<%
					}
				%> 

<%@ include	file="selectsourcestable.jsp"%> 

<!-- end of menu-->


<%-- prepare the data structures --%>
<%@ include file="listSourcesPrepare.jsp" %>





<%
 	String posargs = paramstring + sortstring;

  	if (reverse != null) {
  		posargs += notreversestring;
  	}

  	int maxpos = nrServers - stepsize;
 %>

<h2>Sources</h2>
<div id="Sources-Pagination">
</div><br/>
<div id="ajaxLoaderSources"></div>
<div id="totalSourcesDiv"></div>
<a id="hideSources" href="#hideSources">hide</a> /
<a id="showSources" href="#showSources">show</a>
<div class="sources" id="sourcesDiv">
</div>

	<%
			if (clients != null) {
			out.print("DAS - client legend:<br/>");
			for (int cl = 0; cl < clients.length; cl++) {
				DasClient client = clients[cl];
				String imgPath = client.getIconPath();
				String home = "" + client.getHomepage();
	%>
				<a href="<%=home%>"> 
				<%
 				if (imgPath != null) {
 				%><img src="<%=imgPath%>"></a>
					...
					<a href="<%=home%>"><%=client.getName()%></a>
					<br />
					<%
							}
							}
						}
					%>
<h3>Key:</h3>
<img src="img/red16.gif">Invalid (declared by provider to be used but not valid or required by the specification but not implemented)<br/>
<img src="img/amber16.gif">Probably valid (Registry detected a valid response but the provider has not specified capability)<br/>
<img src="img/green16.gif">Valid (Response is valid)<br/>
<img src="img/clear16.gif">Optional capability<br/>

</div>
</div>

<script src="boxover.js"></script>
<%@ include file="sangerfooter.jsp"%>






